<?php
/**
 * @package Curly
 * @version 0.9
 * @link http://curly.codeplex.com/
 * @license http://curly.codeplex.com/license The MIT License
 * @author Dawid Zawada
 */

namespace Curly
{
    /**
     * Registers an autoloader for Curlys classes.
     *  
     * This autoloader assumes that:
     * - Namespaces represent the directory structure (case sensitive)
     * - Classes are stored in files named: {ClassName}.php (case sensitive)
     */
	spl_autoload_register( function ( $className ) {
	    if( stripos( $className, __NAMESPACE__ ) === 0 )
	    {
    	    $className = substr( $className, strlen( __NAMESPACE__ ) );
    	    $className = str_replace( "\\", "/", $className );
    	    $classPath = __DIR__ . "{$className}.php";
    	    
    	    if( file_exists( $classPath ) )
    	    {
    	        require $classPath;
    	    }
	    }
	} );
}